package com.example.a80205050.myapplication.MyActivity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.a80205050.myapplication.Dao.PwdDao;
import com.example.a80205050.myapplication.Modle.Tb_pwd;
/**
 * Created by 80205050 on 2017/11/1.
 */

public class Sysset extends Activity {
    EditText txtpwd;
    Button btnSet,btnsetCancel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sysset);
        txtpwd=(EditText)findViewById(R.id.txtPwd);
        btnSet=(Button)findViewById(R.id.btnset);
        btnsetCancel=(Button)findViewById(R.id.btnsetCancel);
        btnSet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PwdDao pwdDao=new PwdDao(Sysset.this);
                Tb_pwd tb_pwd=new Tb_pwd(txtpwd.getText().toString());
                if(pwdDao.getCount()==0){
                    pwdDao.add(tb_pwd);
                }else{
                    pwdDao.update(tb_pwd);
                }
                Toast.makeText(Sysset.this,"密码设置成功",Toast.LENGTH_LONG).show();
            }
        });
        btnsetCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                txtpwd.setText(" ");//清空密码框
                txtpwd.setHint("请输入密码");//为密码框输入文本框提示
            }
        });

    }
}
